var webpack = require('webpack');
var path = require('path');
var proxy = require('http-proxy-middleware')

module.exports = {
    entry:'./index.js',
    output:{
        publicPath:'',
        filename:'bundle.js'
    },
    module:{
        loaders:[
            {
                test:/\.js$/,
                exclude: /node_modules/,
                loader:'babel-loader?presets[]=es2015&presets[]=react&presets[]=stage-0'
            },
            {
                test: /\.css$/,
                loaders: 'style-loader!css-loader'
              },
              {
                test: /\.(eot|svg|ttf|woff|woff2)(\?\s*)?$/,
                loader: 'file-loader'
              },
              {
                test: /\.(png|jpe?g|gif|svg)(\?\s*)?$/,
                loader: 'file-loader',
                query:{
                    name:'[name].[ext]?[hash]'
                }
              }
        ]
    },
    devServer:{
        proxy:{//将https://api.douban.com/v2/movie/top250----重写成--->api/v2/movie/top250
            '/api':{
                target:'https://api.douban.com',//设置的是代理对象地址
                pathRewrite:{'^/api':'/'},//重置路径
                changeOrigin:true 
            }

        }
    }
}